def init_brand_data(enging):
    from mall.models.brand import Brand
    from mall.models.product import Product
    import shortuuid
    conn = enging.connect()

    for i in ['魔兽', '传奇', '上古卷轴']:
        conn.execute(Brand.__table__.insert(),
                     id=shortuuid.uuid(),
                     brand_name=i,
                     describe='这是品牌{}的说明'.format(i),
                     logo='',
                     status='normal'
                     )
    brand_table = Brand.__table__

    from sqlalchemy.sql import select

    brands = [b[0] for b in conn.execute(select([brand_table.c.id]))]

    product_table = Product.__table__

    products = [b[0] for b in conn.execute(select([product_table.c.id]))]

    import random
    count = random.randrange(1, len(products))

    for brand in brands:
        for i in range(0, count):
            pid = random.choice(products)
            stmt = product_table.update().values(brand_id=brand).where(product_table.c.id == pid)
            conn.execute(stmt)
